package com.zhn.evsi.domain.entity.evsi;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zhn.evsi.domain.dto.evsi.EvsiTokenDTO;
import com.zhn.evsi.domain.dto.evsi.EvsiVerifyDTO;
import lombok.Data;

import java.util.Date;

@Data
@TableName("evsi_oauth_token")
public class EvsiAuthToken {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("access_token")
    private String accessToken;

    @TableField("token_type")
    private String tokenType;

    @TableField("expires_in")
    private Integer expiresIn;

    @TableField("refresh_token")
    private String refreshToken;

    @TableField("character_id")
    private Integer CharacterID;

    @TableField("character_name")
    private String CharacterName;

    @TableField("expires_on")
    private Date ExpiresOn;

    @TableField("character_owner_hash")
    private String CharacterOwnerHash;

    @TableField("intellectual_property")
    private String IntellectualProperty;

    @TableField("email")
    private String email;


    public EvsiAuthToken splicingToken(EvsiTokenDTO token, EvsiVerifyDTO verify) {
        EvsiAuthToken evsiAuthToken = new EvsiAuthToken();

        evsiAuthToken.setCharacterID(verify.getCharacterID());
        evsiAuthToken.setCharacterName(verify.getCharacterName());
        evsiAuthToken.setExpiresOn(verify.getExpiresOn());
        evsiAuthToken.setCharacterOwnerHash(verify.getCharacterOwnerHash());
        evsiAuthToken.setIntellectualProperty(verify.getIntellectualProperty());
        evsiAuthToken.setAccessToken(token.getAccess_token());
        evsiAuthToken.setRefreshToken(token.getRefresh_token());
        evsiAuthToken.setTokenType(token.getToken_type());
        evsiAuthToken.setExpiresIn(token.getExpires_in());

        return evsiAuthToken;
    }
}
